package com.jcompressor.assertion;

public abstract class AssertArgument {
	
	public static void isNotNull(Object arg, String argName) throws IllegalArgumentException {
		if (arg == null) {
			throw new IllegalArgumentException("null '" + argName + "' arg in method call.");
		}
	}
	
	public static void isNotEmpty(String arg, String argName) throws IllegalArgumentException {
		if (arg != null && arg.trim().length() == 0) {
			throw new IllegalArgumentException("Not null, but empty '" + argName + "' arg in method call.");
		}
	}
	
	public static void isNotBlank(String arg, String argName) throws IllegalArgumentException {
		if (arg == null || arg.trim().length() == 0) {
			throw new IllegalArgumentException("null or empty '" + argName + "' arg in method call.");
		}
	}
	
	public static void isInstanceOf(Object arg, Class clazz, String argName) throws IllegalArgumentException {
		if (clazz.isAssignableFrom(arg.getClass())) {
			throw new IllegalArgumentException("Argument '" + argName + "' is not an instance of '" + clazz.getName() + "'.");
		}
	}
}